Code
library(leaflet)
library(leaflet.extras)
library(RColorBrewer)
darkMapUrl="https://api.mapbox.com/styles/v1/rungdung/cl3jusid0001g15odcz3f1dcb/tiles/256/{z}/{x}/{y}@2x?access_token=pk.eyJ1IjoicnVuZ2R1bmciLCJhIjoiY2tqeWh6cXF4MDgzMjJvbWVmbGQzYjAwMyJ9.U-aJyoqyKvTXlhVk43jV1A"
# Reading in and calibrating data
illuminationTrace<- read.csv("../../resources/assets/illumination-traces-hebbala-nov-2022-18.csv", stringsAsFactors = FALSE)
# CP = Calibration point
## One calibration point was the darkest point, the other was the brightest point
illuminationTrace$callibrated <- ((illuminationTrace$Reading - illuminationTrace$CP2) * 1700)/ (illuminationTrace$CP1 - illuminationTrace$CP2)
# This needs some scientific basis for classification
## Should refer to the standards for street lighting
cuts <- cut(illuminationTrace$callibrated,
labels=c( "low", "medium", "lit", "directly lit"),
breaks=c(0, 200, 1000, 3000,20000),
right=FALSE)
pallete <- colorFactor(brewer.pal(n = 5, name = "RdYlGn"),
domain = cuts)
# plot on map
map <- leaflet(height="70vh"
) %>%
addTiles(urlTemplate = darkMapUrl,
attribution = 'Map data © <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors, Infrastructure layers from SafeYelli volunteers, Imagery © <a href="https://www.mapbox.com/">Mapbox</a>',
options = providerTileOptions(minZoom =15, maxZoom = 17)
) %>%
fitBounds(77.578648,13.036753,77.606285,13.049463) %>%
setMaxBounds(77.564031,13.028562,77.619306,13.053940) %>%
addHeatmap(data = illuminationTrace,
intensity = cuts,
radius = 2,
blur=4,
group = "illumination traces",
max=5,
gradient = pallete(cuts))
mapIllumination data collected from multiple devices. GPS Accuracy threw off the data, but the general trend is clear. Phone light sensors seem to notoriously vary under different conditions, each phone was calibrated under the same light source with a light meter. Values adjust to reflect that